//
//  AboutUsController.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/12/24.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "AboutUsController.h"

@interface AboutUsController ()

@end

@implementation AboutUsController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = WhiteColor;
    
    UIImageView *logoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"titleIvBG"]];
    [self.view addSubview:logoImage];
    [logoImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(Scale_W(30));
        make.size.mas_equalTo(CGSizeMake(jisuan(252), jisuan(80)));
    }];
    
    UILabel *versionLabel = [[UILabel alloc] init];
    versionLabel.text = [NSString stringWithFormat:@"版本号v%@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
    versionLabel.font = Font(30);
    versionLabel.textColor = Color999999;
    [self.view addSubview:versionLabel];
    [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(logoImage.mas_bottom).offset(Scale_W(15));
    }];
    
    UIView *linevvv = [[UIView alloc] init];
    linevvv.backgroundColor = Colordddddd;
    [self.view addSubview:linevvv];
    [linevvv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(Margin);
        make.top.equalTo(versionLabel.mas_bottom).offset(Scale_W(45));
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
    
    NSArray *titleArray = @[@"去评分", @"服务条款", @"隐私政策"];
    for (int i = 0; i < titleArray.count; i ++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.view addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(linevvv.mas_bottom).offset(i*Scale_W(50));
            make.left.mas_equalTo(Margin);
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(Scale_W(50));
        }];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = titleArray[i];
        titleLabel.textColor = Color333333;
        titleLabel.font = Font(30);
        [button addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.centerY.equalTo(button.mas_centerY);
        }];
        
        UIView *linev = [[UIView alloc] init];
        linev.backgroundColor = Colordddddd;
        [button addSubview:linev];
        [linev mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
        
        UIImageView *rightImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"settingRigthArrowBG"]];
        [button addSubview:rightImage];
        [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-Margin);
            make.centerY.equalTo(button.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(Scale_W(6), Scale_W(10)));
        }];
        button.tag = 1000+i;
        [button addTarget:self action:@selector(buttonTypeClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    UILabel *copyrightLabel = [[UILabel alloc] init];
    copyrightLabel.textColor = Colordddddd;
    copyrightLabel.numberOfLines = 0;
    copyrightLabel.textAlignment = NSTextAlignmentCenter;
    copyrightLabel.font = Font(24);
    copyrightLabel.text = @"紫电火石 版权所有\nCopright@2019 紫电火石.All Rights Reserved";
    [self.view addSubview:copyrightLabel];
    [copyrightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.bottom.mas_equalTo(-20);
    }];
}

- (void)buttonTypeClick:(UIButton *)button {
    
    switch (button.tag) {
        case 1000:
            {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/cn/app/id1453275811?mt=8"]];
            }
            break;
        case 1001:
        {
            WebViewController *vc = [[WebViewController alloc] init];
            vc.title = @"用户协议";
            vc.url = @"http://aitaobang.haoyunkaikai.com/H5/xieyi/agreement.html";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1002:
        {
            WebViewController *vc = [[WebViewController alloc] init];
            vc.title = @"隐私政策";
            vc.url = @"http://aitaobang.haoyunkaikai.com/H5/xieyi/conceal.html";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
}


@end
